package com.itestor.iptv.modules.ne.actions;


import java.util.List;

import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import com.itestor.iptv.global.actions.AbstractPagedQueryAction;
import com.itestor.iptv.global.bean.AbstractPagedQuery;
import com.itestor.iptv.modules.common.domain.GroupManage;
import com.itestor.iptv.modules.common.service.GroupManageService;
import com.itestor.iptv.modules.ne.bean.RobotSelectQuery;
import com.itestor.iptv.modules.ne.service.RobotManageService;

/**
 * 
 * @author Mr.li
 * 
 */
public class RobotSelectQueryAction extends AbstractPagedQueryAction {

    /**
     * Logger for this class.
     */
    private static final Logger logger = Logger
            .getLogger(RobotSelectQueryAction.class);

    private RobotManageService robotManageService;
    
    private GroupManageService groupManageService;
    
    /* (non-Javadoc)
     * @see com.itestor.iptv.global.actions.AbstractPagedQueryAction#doPagedQuery(org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, int, int)
     */
    @Override   
    public AbstractPagedQuery doPagedQuery(ActionForm form,
            HttpServletRequest request, int pagerCount, int pagerOffset)
            throws Exception {
        
        String queryIdGroup = request.getParameter("queryIdGroup");
        
        RobotSelectQuery robotSelectQuery = new RobotSelectQuery();        
        robotSelectQuery.setPagerCount(pagerCount);
        robotSelectQuery.setPagerOffset(pagerOffset);
        
        if (!StringUtils.isEmpty(queryIdGroup)) {
            robotSelectQuery.setQueryIdGroup(Integer.parseInt(queryIdGroup)); 
            request.setAttribute("queryIdGroup",queryIdGroup);
        }
        
        List<GroupManage> groupManageList= groupManageService.findAllGroupManage();        
        request.setAttribute("groupManageList", groupManageList);
        
        robotManageService.queryRobotSelectList(robotSelectQuery); 
        
        logger.info("groupManageList :" +groupManageList.size());
        
        return robotSelectQuery;
    }
    
    /**
     * 　
     * @param pRobotManageService
     */
    public void setRobotManageService(RobotManageService pRobotManageService) {
        robotManageService = pRobotManageService;
    }
    /**
     * 
     * @param pGroupManageService
     */
    public void setGroupManageService(GroupManageService pGroupManageService) {
        groupManageService = pGroupManageService;
    }
    
    


}